package com.hctforgreen.greenservice.machineManager.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Parcel;
import android.text.InputFilter;
import android.text.method.DigitsKeyListener;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.hctforgreen.greenservice.R;
import com.hctforgreen.greenservice.StartPwdActivity;
import com.hctforgreen.greenservice.machineManager.MachineBase;
import com.hctforgreen.greenservice.model.BigUnitEntity;
import com.hctforgreen.greenservice.model.LQTPumpEntity;
import com.hctforgreen.greenservice.model.LocationEntity;
import com.hctforgreen.greenservice.model.PwdEntity;
import com.hctforgreen.greenservice.model.RHSPumpEntity;
import com.hctforgreen.greenservice.model.RYPumpEntity;
import com.hctforgreen.greenservice.model.SYPumpEntity;
import com.hctforgreen.greenservice.utils.HctResult;
import com.hctforgreen.greenservice.utils.LoginResultStoreUtil;
import com.hctforgreen.greenservice.utils.MachineCodeUtil;
import com.hctforgreen.greenservice.utils.Utils;
/**
 * 大机组
 * @author 390694
 *
 */
public class Bigunit extends MachineBase implements Serializable{

	private View layout_bigUnit;
	
	private EditText useArea_edit;
	/**
	 * 泵类型数组
	 */
	private String[] pumpTypeItems;
	// 大机组--是否已经上电
	private boolean isPowerUp = false;
	// 大机组的使用面积
	private String useAreaForBigUnit;
	/**
	 * 弹出对话框时统计每个泵添加数量,以便后面删除时做操作
	 */
	private int sourceOfHeatPumpNum = 0;// 热源泵
	private int heapRecoveryPumpNum = 0;// 热回收泵
	private int coolingTowerNum = 0;// 冷却塔
	private int usingPumpNum = 0;// 使用泵
	
	/**
	 * 在提交时每个泵的数量
	 */
	private int sub_RHSPumpNum = 0;
	private int sub_SYPumpNum = 0;
	private int sub_LQTPumpNum = 0;
	private int sub_RYPumpNum = 0;

	/**
	 * 大机组开机密码状态改变通知条数
	 */
	private int bigUnitPwdStatusMsg = 0;

	/**
	 * 存放添加的各种泵数量
	 */
	private HashMap<String, Integer> amountOfPump = new HashMap<String, Integer>();
	/**
	 * 大机组数据
	 */
	public BigUnitEntity dataForBigUnit;

	/**
	 * 热回收泵数据
	 */
	private ArrayList<RHSPumpEntity> listRHS = new ArrayList<RHSPumpEntity>();
	/**
	 * 使用泵数据
	 */
	private ArrayList<SYPumpEntity> listSY = new ArrayList<SYPumpEntity>();
	/**
	 * 热源泵数据
	 */
	private ArrayList<RYPumpEntity> listRY = new ArrayList<RYPumpEntity>();
	/**
	 * 冷却塔数据
	 */
	private ArrayList<LQTPumpEntity> listLQT = new ArrayList<LQTPumpEntity>();
	
	
	
	public BigUnitEntity getDataForBigUnit() {
		return dataForBigUnit;
	}


	public Bigunit(Activity context) {
		super(context);
		//390697 屏蔽是为了在机型提示的关联资料中去获取开机密码
//		initView();
	}

	@Override
	public void initView() {
		layout_bigUnit = findViewById(R.id.Layout_bigUnit);
		useArea_edit = (EditText) findViewById(R.id.edit_input_Usearea);
		pumpTypeItems = getResources().getStringArray(R.array.bigunit_pumpType);
		Button bt_addEquipment = (Button) findViewById(R.id.bt_bigUnit_add_equipment);
		bt_addEquipment.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				AlertDialog.Builder builder = new AlertDialog.Builder(activity);
				builder.setTitle(getString(R.string.bigunit_pumpType));
				builder.setItems(pumpTypeItems,
						new MyalertDialogItemClickListener());
				builder.create();
				builder.show();

			}

		});

		CheckBox cb_powerUp = (CheckBox) findViewById(R.id.checkbox_bigunit_is_power_up);
		cb_powerUp
				.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton arg0,
							boolean arg1) {
						isPowerUp = arg1;
					}
				});
		
	}

	@Override
	public void showView() {
		layout_bigUnit.setVisibility(View.VISIBLE);
		
	}

	@Override
	public void hideView() {
		layout_bigUnit.setVisibility(View.GONE);
		
	}

	@Override
	public boolean validateView() {
		useAreaForBigUnit = useArea_edit.getText().toString();
		if(useAreaForBigUnit.isEmpty()){
			Utils.showToastCenter(activity,
					getString(R.string.barcode_info_is_incomplete));
			return false;
		}
		if (isPowerUp == false) {
			Toast.makeText(activity,
					R.string.bigUnit_mustPowerUp,
					Toast.LENGTH_SHORT).show();
			return false;
		}

		if (sub_LQTPumpNum != 0 || sub_RHSPumpNum != 0
				&& sub_RYPumpNum != 0 || sub_SYPumpNum != 0) {
			sub_LQTPumpNum = sub_RHSPumpNum = sub_RYPumpNum = sub_SYPumpNum = 0;
		}
		if (!amountOfPump.isEmpty()) {
			amountOfPump.clear();
		}
		if (!listRHS.isEmpty() || !listSY.isEmpty()
				|| !listRY.isEmpty() || !listLQT.isEmpty()) {
			listRHS.clear();
			listLQT.clear();
			listRY.clear();
			listSY.clear();
		}

		// 计算添加的每个泵的数量
		traversalView((LinearLayout) (findViewById(R.id.layout_bigUnit_add_equipment)));

		amountOfPump.put("sub_LQTPumpNum", sub_LQTPumpNum);
		amountOfPump.put("sub_RHSPumpNum", sub_RHSPumpNum);
		amountOfPump.put("sub_RYPumpNum", sub_RYPumpNum);
		amountOfPump.put("sub_SYPumpNum", sub_SYPumpNum);


		dataForBigUnit = new BigUnitEntity();
		LinearLayout bigUnitLyt = (LinearLayout) findViewById(R.id.layout_bigUnit_add_equipment);
		// 获取每个泵的数据存入dataForBigUnit中
		getDataForRHSPump(bigUnitLyt);
		getDataForSYPump(bigUnitLyt);
		getDataForRYPump(bigUnitLyt);
		getDataForLQTPump(bigUnitLyt);
		dataForBigUnit.setPowered(isPowerUp);
		dataForBigUnit.setUsedArea(useAreaForBigUnit);
		return true;
	}


	@Override
	public HctResult getPwdResult(PwdEntity paramEntity,LocationEntity locationEntity, boolean isClounServer) throws Exception {
		HctResult result = new HctResult();
		
		dataForBigUnit.setBarcode(paramEntity.stripeCode);
		dataForBigUnit.setPhone(paramEntity.phone);

		dataForBigUnit.setPersonId(LoginResultStoreUtil
				.get(activity).personId);
		dataForBigUnit.setProvince(locationEntity.getProvince());
		dataForBigUnit.setCity(locationEntity.getCity());
		dataForBigUnit.setRegion(locationEntity.getDistrict());
		dataForBigUnit.setStreet(paramEntity.street);
		dataForBigUnit.setProjectName(paramEntity.projectName);
		dataForBigUnit.setIndustry(paramEntity.industry);
		dataForBigUnit.setManager(paramEntity.ownerName);
		dataForBigUnit.setManagerPhone(paramEntity.ownerPhone);
		dataForBigUnit.setPowered(isPowerUp);
		dataForBigUnit.setRemark(paramEntity.remark);
		dataForBigUnit.setSearchDate(Utils.getNowDate());
		dataForBigUnit.setUsedArea(useAreaForBigUnit);
		dataForBigUnit.setBakProvince(locationEntity.getProvince_loc());
		dataForBigUnit.setBakCity(locationEntity.getCity_loc());
		dataForBigUnit.setLongitude(Double.toString(locationEntity.getmLongitude()));
		dataForBigUnit.setLatitude(Double.toString(locationEntity.getmLatitude()));
		dataForBigUnit.setIdentityCode(getNowDateAsIdentityCode());
		result = controller.submitBigUnitInfo(dataForBigUnit,
				locationEntity.getmGpsLocation(),locationEntity.getmBaseLocation(),locationEntity.getmWifiLocation(), isClounServer);
		return result;
	}

	//关联提示页面用到
	public HctResult getPwdResult(PwdEntity paramEntity,LocationEntity locationEntity, boolean isClounServer,BigUnitEntity dataForBigUnit) throws Exception {
		HctResult result = new HctResult();

		dataForBigUnit.setBarcode(paramEntity.stripeCode);
		dataForBigUnit.setPhone(paramEntity.phone);

		dataForBigUnit.setPersonId(LoginResultStoreUtil
				.get(activity).personId);
		dataForBigUnit.setProvince(locationEntity.getProvince());
		dataForBigUnit.setCity(locationEntity.getCity());
		dataForBigUnit.setRegion(locationEntity.getDistrict());
		dataForBigUnit.setStreet(paramEntity.street);
		dataForBigUnit.setProjectName(paramEntity.projectName);
		dataForBigUnit.setIndustry(paramEntity.industry);
		dataForBigUnit.setManager(paramEntity.ownerName);
		dataForBigUnit.setManagerPhone(paramEntity.ownerPhone);
		dataForBigUnit.setRemark(paramEntity.remark);
		dataForBigUnit.setSearchDate(Utils.getNowDate());
		dataForBigUnit.setBakProvince(locationEntity.getProvince_loc());
		dataForBigUnit.setBakCity(locationEntity.getCity_loc());
		dataForBigUnit.setLongitude(Double.toString(locationEntity.getmLongitude()));
		dataForBigUnit.setLatitude(Double.toString(locationEntity.getmLatitude()));
		dataForBigUnit.setIdentityCode(getNowDateAsIdentityCode());
		result = controller.submitBigUnitInfo(dataForBigUnit,
				locationEntity.getmGpsLocation(),locationEntity.getmBaseLocation(),locationEntity.getmWifiLocation(), isClounServer);
		return result;
	}

	/**
	 * 大机组特有属性——添加配套设备
	 */
	private void setBigUnitEquipmentValue(String pumpType) {

		// 获取大机组主布局中的添加设备的LinearLayout布局
		LinearLayout llayout_addEquipment = (LinearLayout) findViewById(R.id.layout_bigUnit_add_equipment);

		LinearLayout.LayoutParams llayoutParames1 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		llayoutParames1.setMargins(0, 12, 0, 0);

		// 将子布局添加到主布局
		llayout_addEquipment.addView(buildViewForBigUnit(pumpType),
				llayoutParames1);

	}
	/**
	 * 动态添加控件
	 * 
	 * @return
	 */
	@SuppressWarnings("deprecation")
	private LinearLayout buildViewForBigUnit(final String pumpType) {
		// 添加一个子布局，用于控制控件的格式
		final LinearLayout llayout_childUi = new LinearLayout(activity);
		llayout_childUi.setOrientation(1);
		llayout_childUi.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.input_box));

		// 第一个布局-泵类型 ---泵类型
		LinearLayout llayout_pumpType = new LinearLayout(activity);
		LinearLayout.LayoutParams llayoutParames2 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		llayout_pumpType.setLayoutParams(llayoutParames2);
		llayout_pumpType.setOrientation(0);

		// 泵类型
		TextView tv_pumpType = new TextView(activity);
		tv_pumpType.setText("泵类型:");
		LinearLayout.LayoutParams pumpTypeParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv_pumpType.setLayoutParams(pumpTypeParames);
		tv_pumpType.setTextColor(getResources().getColor(R.color.black));
		tv_pumpType.setTextSize(18);

		TextView tv_pumpTypeNote = new TextView(activity);
		tv_pumpTypeNote.setText(pumpType);
		tv_pumpTypeNote.setTag(pumpType);
		tv_pumpTypeNote.setTextColor(getResources().getColor(R.color.black));
		tv_pumpTypeNote.setTextSize(18);
		tv_pumpTypeNote.setGravity(Gravity.LEFT);
		LinearLayout.LayoutParams tv_pumpTypeParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT, 1);
		tv_pumpTypeParames.leftMargin = 20;
		tv_pumpTypeNote.setLayoutParams(tv_pumpTypeParames);

		Button deleteBtn = new Button(activity);
		deleteBtn.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.ic_video_delete_normal));
		RelativeLayout.LayoutParams deleteBtnParames1 = new RelativeLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		deleteBtnParames1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		deleteBtnParames1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		deleteBtn.setLayoutParams(deleteBtnParames1);
		deleteBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (pumpType.equals("热源泵") && sourceOfHeatPumpNum > 0) {
					sourceOfHeatPumpNum--;

				} else if (pumpType.equals("热回收泵") && heapRecoveryPumpNum > 0) {
					heapRecoveryPumpNum--;

					Log.i("DATA", "heapRecoveryPumpNum2=="
							+ heapRecoveryPumpNum);
				} else if (pumpType.equals("冷却塔") && coolingTowerNum > 0) {
					coolingTowerNum--;

				} else if (pumpType.equals("使用泵") && usingPumpNum > 0) {
					usingPumpNum--;

				}

				if (sub_RYPumpNum > 0) {
					sub_RYPumpNum--;
				}
				if (sub_RHSPumpNum > 0) {
					sub_RHSPumpNum--;
				}
				if (sub_LQTPumpNum > 0) {
					sub_LQTPumpNum--;
				}
				if (sub_SYPumpNum > 0) {
					sub_SYPumpNum--;
				}
				((LinearLayout) findViewById(R.id.layout_bigUnit_add_equipment))
						.removeView(llayout_childUi);

			}
		});

		// 第二个布局-泵类型 ---厂家
		LinearLayout llayout_manufacturers = new LinearLayout(activity);
		LinearLayout.LayoutParams llayoutParames3 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		llayoutParames3.topMargin = 20;
		llayout_manufacturers.setLayoutParams(llayoutParames3);
		llayout_manufacturers.setOrientation(0);

		// 厂家
		TextView tv_manufacturers = new TextView(activity);
		tv_manufacturers.setText("厂家:");
		LinearLayout.LayoutParams manufacturersParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv_manufacturers.setLayoutParams(manufacturersParames);
		tv_manufacturers.setTextColor(getResources().getColor(R.color.black));
		tv_manufacturers.setTextSize(14);

		EditText edit_manufacturers = new EditText(activity);
		// edit_manufacturers.setId(viewId + 1);
		//
		// Log.i("DATA", "edit_manufacturers的ID" + (viewId + 1));

		edit_manufacturers.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.input_box));
		edit_manufacturers.setSingleLine();
		edit_manufacturers.setTextColor(getResources().getColor(R.color.black));
		edit_manufacturers.setTextSize(14);
		edit_manufacturers.setTag(pumpType + "厂家");
		// Log.i("DATA", pumpType+"厂家");
		LinearLayout.LayoutParams edit_manufacturersParames = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT, 1);
		edit_manufacturersParames.leftMargin = 30;
		edit_manufacturers.setLayoutParams(edit_manufacturersParames);
		// // 将控件ID存入数组
		// edit_manufacturersViewId[addButtonClickNum - 1] = viewId + 1;

		// 第三个布局-型号 ---型号
		LinearLayout llayout_pumpModelNumber = new LinearLayout(activity);
		LinearLayout.LayoutParams pumpModelNumberParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		pumpModelNumberParames.topMargin = 20;
		llayout_pumpModelNumber.setLayoutParams(pumpModelNumberParames);
		llayout_pumpModelNumber.setOrientation(0);

		// 型号
		TextView tv_pumpModelNumber = new TextView(activity);
		tv_pumpModelNumber.setText("型号:");
		tv_pumpModelNumber.setTextColor(getResources().getColor(R.color.black));
		tv_pumpModelNumber.setTextSize(14);
		LinearLayout.LayoutParams pumpModelNumberParame = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv_pumpModelNumber.setLayoutParams(pumpModelNumberParame);

		EditText edit_pumpModelNumber = new EditText(activity);
		edit_pumpModelNumber.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.input_box));
		edit_pumpModelNumber.setSingleLine();
		edit_pumpModelNumber.setTextColor(getResources()
				.getColor(R.color.black));
		edit_pumpModelNumber.setTextSize(14);
		edit_pumpModelNumber.setTag(pumpType + "型号");
		// edit_pumpModelNumber.setKeyListener(new numericOnlyListener());
		LinearLayout.LayoutParams edit_pumpModelNumberParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT, 1);
		edit_pumpModelNumberParames.leftMargin = 30;
		edit_pumpModelNumber.setLayoutParams(edit_pumpModelNumberParames);

		// 第四个布局-流量 ---流量、扬程
		LinearLayout llayout_pumpFlow = new LinearLayout(activity);
		LinearLayout.LayoutParams pumpFlowParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		pumpFlowParames.topMargin = 20;
		llayout_pumpFlow.setLayoutParams(pumpFlowParames);
		llayout_pumpFlow.setOrientation(0);

		// 流量
		TextView tv_pumpFlow = new TextView(activity);
		tv_pumpFlow.setText("流量:");
		LinearLayout.LayoutParams pumpFlowParames1 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv_pumpFlow.setLayoutParams(pumpFlowParames1);
		tv_pumpFlow.setTextColor(getResources().getColor(R.color.black));
		tv_pumpFlow.setTextSize(14);

		EditText edit_pumpFlow = new EditText(activity);
		edit_pumpFlow.setSingleLine();
		edit_pumpFlow.setTextColor(getResources().getColor(R.color.black));
		edit_pumpFlow.setTextSize(14);
		edit_pumpFlow.setTag(pumpType + "流量");
		edit_pumpFlow.setKeyListener(new numericOnlyListener());
		// 设置可输入的字符长度
		// InputFilter[] filters = {new InputFilter.LengthFilter(10)};

		edit_pumpFlow
				.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) });
		edit_pumpFlow.setBackgroundDrawable(getResources().getDrawable(
				R.drawable.input_box));
		LinearLayout.LayoutParams edit_pumpFlowParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT, 1);
		edit_pumpFlowParames.leftMargin = 30;
		edit_pumpFlow.setLayoutParams(edit_pumpFlowParames);

		TextView tv_pumpFlowUnit = new TextView(activity);
		tv_pumpFlowUnit.setText("m^3/h");
		tv_pumpFlowUnit.setTextColor(getResources().getColor(R.color.black));
		tv_pumpFlowUnit.setTextSize(14);
		LinearLayout.LayoutParams pumpFlowUnitParames1 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WRAP_CONTENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		tv_pumpFlowUnit.setLayoutParams(pumpFlowUnitParames1);

		// 第五个布局-、扬程
		LinearLayout llayout_pumpLift = new LinearLayout(activity);
		LinearLayout.LayoutParams pumpLiftParames = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.WRAP_CONTENT);
		pumpLiftParames.topMargin = 20;
		llayout_pumpLift.setLayoutParams(pumpLiftParames);
		llayout_pumpLift.setOrientation(0);

		if (pumpType.equals("冷却塔")) {
			TextView tv_power = new TextView(activity);
			tv_power.setText("能力:");
			tv_power.setLayoutParams(pumpFlowParames1);
			tv_power.setTextColor(getResources().getColor(R.color.black));
			tv_power.setTextSize(14);

			EditText edit_power = new EditText(activity);
			edit_power.setSingleLine();
			edit_power.setBackgroundDrawable(getResources().getDrawable(
					R.drawable.input_box));
			edit_power.setTextColor(getResources().getColor(R.color.black));
			edit_power.setTextSize(14);
			edit_power.setTag(pumpType + "能力");
			edit_power.setKeyListener(new numericOnlyListener());
			edit_power
					.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
							4) });
			LinearLayout.LayoutParams edit_powerParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1);
			edit_powerParames.leftMargin = 30;
			edit_power.setLayoutParams(edit_powerParames);

			TextView tv_number = new TextView(activity);
			tv_number.setText("数量:");
			LinearLayout.LayoutParams numberParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			numberParames.leftMargin = 20;
			tv_number.setLayoutParams(numberParames);
			tv_number.setTextColor(getResources().getColor(R.color.black));
			tv_number.setTextSize(14);

			EditText edit_number = new EditText(activity);
			edit_number.setSingleLine();
			edit_number.setBackgroundDrawable(getResources().getDrawable(
					R.drawable.input_box));
			edit_number.setTextColor(getResources().getColor(R.color.black));
			edit_number.setTextSize(14);
			edit_number.setTag(pumpType + "数量");
			edit_number.setKeyListener(new numericOnlyListener());
			edit_number
					.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
							2) });
			LinearLayout.LayoutParams edit_numberParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1);
			edit_numberParames.leftMargin = 10;
			edit_number.setLayoutParams(edit_numberParames);

			llayout_pumpLift.addView(tv_power);
			llayout_pumpLift.addView(edit_power);

			llayout_pumpLift.addView(tv_number);
			llayout_pumpLift.addView(edit_number);

		} else {

			// 扬程
			TextView tv_pumpLift = new TextView(activity);
			tv_pumpLift.setText("扬程:");
			tv_pumpLift.setTextColor(getResources().getColor(R.color.black));
			tv_pumpLift.setTextSize(14);
			LinearLayout.LayoutParams pumpLiftParames1 = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.WRAP_CONTENT,
					ViewGroup.LayoutParams.WRAP_CONTENT);
			tv_pumpLift.setLayoutParams(pumpLiftParames1);

			EditText edit_pumpLift = new EditText(activity);
			edit_pumpLift.setSingleLine();
			edit_pumpLift.setBackgroundDrawable(getResources().getDrawable(
					R.drawable.input_box));
			edit_pumpLift.setTextColor(getResources().getColor(R.color.black));
			edit_pumpLift.setTextSize(14);
			edit_pumpLift.setTag(pumpType + "扬程");
			edit_pumpLift.setKeyListener(new numericOnlyListener());
			edit_pumpLift
					.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
							3) });
			LinearLayout.LayoutParams edit_pumpLiftParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1);
			edit_pumpLiftParames.leftMargin = 30;
			edit_pumpLift.setLayoutParams(edit_pumpLiftParames);

			TextView tv_pumpLiftUnit = new TextView(activity);
			tv_pumpLiftUnit.setText("m;");
			tv_pumpLiftUnit.setLayoutParams(pumpFlowUnitParames1);
			tv_pumpLiftUnit
					.setTextColor(getResources().getColor(R.color.black));
			tv_pumpLiftUnit.setTextSize(14);

			EditText edit_pumpMainUse = new EditText(activity);
			edit_pumpMainUse.setSingleLine();
			edit_pumpMainUse.setBackgroundDrawable(getResources().getDrawable(
					R.drawable.input_box));
			edit_pumpMainUse.setTextColor(getResources()
					.getColor(R.color.black));
			edit_pumpMainUse.setTextSize(14);
			edit_pumpMainUse.setTag(pumpType + "用");
			edit_pumpMainUse.setKeyListener(new numericOnlyListener());
			edit_pumpMainUse
					.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
							2) });
			LinearLayout.LayoutParams edit_pumpMainUseParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1);
			edit_pumpMainUseParames.leftMargin = 20;
			edit_pumpMainUse.setLayoutParams(edit_pumpMainUseParames);

			TextView tv_pumpMainUseUnit = new TextView(activity);
			tv_pumpMainUseUnit.setText("用");
			tv_pumpMainUseUnit.setLayoutParams(pumpFlowUnitParames1);
			tv_pumpMainUseUnit.setTextColor(getResources().getColor(
					R.color.black));
			tv_pumpMainUseUnit.setTextSize(14);

			EditText edit_pumpStandby = new EditText(activity);
			edit_pumpStandby.setSingleLine();
			edit_pumpStandby.setBackgroundDrawable(getResources().getDrawable(
					R.drawable.input_box));
			edit_pumpStandby.setTextColor(getResources()
					.getColor(R.color.black));
			edit_pumpStandby.setTextSize(14);
			edit_pumpStandby.setTag(pumpType + "备");
			edit_pumpStandby.setKeyListener(new numericOnlyListener());
			edit_pumpStandby
					.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
							2) });
			LinearLayout.LayoutParams edit_StandbyParames = new LinearLayout.LayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1);
			edit_StandbyParames.leftMargin = 20;
			edit_pumpStandby.setLayoutParams(edit_StandbyParames);

			TextView tv_StandbyUnit = new TextView(activity);
			tv_StandbyUnit.setText("备");
			tv_StandbyUnit.setLayoutParams(pumpFlowUnitParames1);
			tv_StandbyUnit.setTextColor(getResources().getColor(R.color.black));
			tv_StandbyUnit.setTextSize(14);

			llayout_pumpLift.addView(tv_pumpLift);
			llayout_pumpLift.addView(edit_pumpLift);
			llayout_pumpLift.addView(tv_pumpLiftUnit);

			llayout_pumpLift.addView(edit_pumpMainUse);
			llayout_pumpLift.addView(tv_pumpMainUseUnit);

			llayout_pumpLift.addView(edit_pumpStandby);
			llayout_pumpLift.addView(tv_StandbyUnit);
		}

		// 将控件添加到子布局

		llayout_pumpType.addView(tv_pumpType);
		llayout_pumpType.addView(tv_pumpTypeNote);
		llayout_pumpType.addView(deleteBtn);
		llayout_childUi.addView(llayout_pumpType);

		llayout_manufacturers.addView(tv_manufacturers);
		llayout_manufacturers.addView(edit_manufacturers);
		llayout_childUi.addView(llayout_manufacturers);

		llayout_pumpModelNumber.addView(tv_pumpModelNumber);
		llayout_pumpModelNumber.addView(edit_pumpModelNumber);
		llayout_childUi.addView(llayout_pumpModelNumber);

		llayout_pumpFlow.addView(tv_pumpFlow);
		llayout_pumpFlow.addView(edit_pumpFlow);
		llayout_pumpFlow.addView(tv_pumpFlowUnit);
		llayout_childUi.addView(llayout_pumpFlow);

		// llayout_childUi.addView(llayout_pumpLift);

		// llayout_useNumber.addView(tempDiverce);

		llayout_childUi.addView(llayout_pumpLift);

		return llayout_childUi;
	}

	class numericOnlyListener extends DigitsKeyListener {

		@Override
		public int getInputType() {

			return android.text.InputType.TYPE_CLASS_NUMBER;
		}
	}
	/**
	 * @创建内部类实现点击添加配套设备时弹出的对话框监听接口
	 */
	class MyalertDialogItemClickListener implements
			DialogInterface.OnClickListener {

		private String pumpType;

		@Override
		public void onClick(DialogInterface arg0, int arg1) {
			this.pumpType = pumpTypeItems[arg1];
			if (this.pumpType.equals("热源泵")) {
				sourceOfHeatPumpNum++;

				if (sourceOfHeatPumpNum > 3) {
					sourceOfHeatPumpNum--;
					Toast.makeText(activity, "热源泵只能添加3个！", Toast.LENGTH_LONG)
							.show();
				} else {
					setBigUnitEquipmentValue(this.pumpType);

				}

			} else if (this.pumpType.equals("热回收泵")) {
				heapRecoveryPumpNum++;
				// Log.i("DATA", "heapRecoveryPumpNum1==" +
				// heapRecoveryPumpNum);
				if (heapRecoveryPumpNum > 2) {
					heapRecoveryPumpNum--;
					Toast.makeText(activity, "热回收泵只能添加2个！", Toast.LENGTH_LONG)
							.show();
				} else {
					setBigUnitEquipmentValue(this.pumpType);

				}
			} else if (this.pumpType.equals("冷却塔")) {
				coolingTowerNum++;
				if (coolingTowerNum > 2) {
					coolingTowerNum--;
					Toast.makeText(activity, "冷却塔只能添加2个！", Toast.LENGTH_LONG)
							.show();
				} else {
					setBigUnitEquipmentValue(this.pumpType);

				}

			} else if (this.pumpType.equals("使用泵")) {
				usingPumpNum++;
				if (usingPumpNum > 3) {
					usingPumpNum--;
					Toast.makeText(activity, "使用泵只能添加3个！", Toast.LENGTH_LONG)
							.show();
				} else {
					setBigUnitEquipmentValue(this.pumpType);

				}
			}

		}
	}
	/**
	 * 递归遍历所有组件
	 * 计算在提交时各个泵的数量：sub_RHSPumpNum、sub_SYPumpNum、sub_LQTPumpNum、sub_RYPumpNum
	 * 
	 * 
	 * @param viewGroup
	 *            LinearLayout
	 */
	public void traversalView(ViewGroup viewGroup) {
		int count = viewGroup.getChildCount();
		for (int i = 0; i < count; i++) {
			View view = viewGroup.getChildAt(i);
			if (view instanceof ViewGroup) {
				traversalView((ViewGroup) view);
			} else {
				doView(view);
			}
		}

	}

	/**
	 * 计算在提交时各个泵的数量：sub_RHSPumpNum、sub_SYPumpNum、sub_LQTPumpNum、sub_RYPumpNum
	 * 
	 * @param view
	 * 
	 */
	private void doView(View view) {

		if (view instanceof TextView) {
			if (((TextView) view).getText().toString().equals("热回收泵")) {
				sub_RHSPumpNum++;
				// Log.i("DATA--doView()方法", ((TextView) view).getText()
				// .toString());

			}
			if (((TextView) view).getText().toString().equals("使用泵")) {
				sub_SYPumpNum++;
			}
			if (((TextView) view).getText().toString().equals("冷却塔")) {
				sub_LQTPumpNum++;
			}
			if (((TextView) view).getText().toString().equals("热源泵")) {
				sub_RYPumpNum++;
			}
		}

	}

	/**
	 * 递归遍历所有动态添加的组件,获取用户输入的热回收泵数据
	 * 
	 * @param viewGroup
	 *            LinearLayout
	 */

	public ArrayList<RHSPumpEntity> traversalViewForRHS(ViewGroup viewGroup) {
		int count = viewGroup.getChildCount();

		RHSPumpEntity mRhsPumpEntity = null;
		for (int i = 0; i < count; i++) {
			mRhsPumpEntity = new RHSPumpEntity();
			View view = viewGroup.getChildAt(i);
			if (view instanceof ViewGroup) {
				traversalViewForRHS((ViewGroup) view);
			} else {
				if (view instanceof TextView) {
					if (((TextView) view).getText().toString().equals("热回收泵")) {
						mRhsPumpEntity.setPumpRHS(((TextView) view).getText()
								.toString());
						Log.i("DATA", "获得泵类型");

					}
				}
				if (view instanceof EditText) {

					if (((EditText) view).getTag().equals("热回收泵厂家")) {
						mRhsPumpEntity.setManufactorRHS(((EditText) view)
								.getText().toString());

					} else if (((EditText) view).getTag().equals("热回收泵型号")) {
						mRhsPumpEntity.setModelRHS(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热回收泵流量")) {
						mRhsPumpEntity.setFlowRHS(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热回收泵扬程")) {
						mRhsPumpEntity.setLiftRHS(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热回收泵用")) {
						mRhsPumpEntity.setQuantityRHS(((EditText) view)
								.getText().toString());
						// Log.i("DATA", "获得主用");
					} else if (((EditText) view).getTag().equals("热回收泵备")) {
						mRhsPumpEntity.setDeviceRHS(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得备用");

					}
				}
			}
			listRHS.add(mRhsPumpEntity);
		}
		return listRHS;

	}

	/**
	 * 递归遍历所有动态添加的组件,获取用户输入的使用泵数据
	 * 
	 * @param viewGroup
	 *            LinearLayout
	 */

	public ArrayList<SYPumpEntity> traversalViewForSY(ViewGroup viewGroup) {

		int count = viewGroup.getChildCount();
		SYPumpEntity mSyPumpEntity = null;
		for (int i = 0; i < count; i++) {
			mSyPumpEntity = new SYPumpEntity();
			View view = viewGroup.getChildAt(i);
			if (view instanceof ViewGroup) {
				traversalViewForSY((ViewGroup) view);
			} else {
				if (view instanceof TextView) {
					if (((TextView) view).getText().toString().equals("使用泵")) {
						mSyPumpEntity.setPumpSY(((TextView) view).getText()
								.toString());
					}
				}
				if (view instanceof EditText) {

					if (((EditText) view).getTag().equals("使用泵厂家")) {
						mSyPumpEntity.setManufactorSY(((EditText) view)
								.getText().toString());

					} else if (((EditText) view).getTag().equals("使用泵型号")) {
						mSyPumpEntity.setModelSY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("使用泵流量")) {
						mSyPumpEntity.setFlowSY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("使用泵扬程")) {
						mSyPumpEntity.setLiftSY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("使用泵用")) {
						mSyPumpEntity.setQuantitySY(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得主用");
					} else if (((EditText) view).getTag().equals("使用泵备")) {
						mSyPumpEntity.setDeviceSY(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得备用");

					}
				}
			}
			listSY.add(mSyPumpEntity);
		}
		return listSY;

	}

	/**
	 * 递归遍历所有动态添加的组件,获取用户输入的热源泵数据
	 * 
	 * @param viewGroup
	 *            LinearLayout
	 */

	public ArrayList<RYPumpEntity> traversalViewForRY(ViewGroup viewGroup) {

		int count = viewGroup.getChildCount();
		RYPumpEntity mRYPumpEntity = null;
		for (int i = 0; i < count; i++) {
			mRYPumpEntity = new RYPumpEntity();
			View view = viewGroup.getChildAt(i);
			if (view instanceof ViewGroup) {
				traversalViewForRY((ViewGroup) view);
			} else {
				if (view instanceof TextView) {
					if (((TextView) view).getText().toString().equals("热源泵")) {
						mRYPumpEntity.setPumpRY(((TextView) view).getText()
								.toString());
					}
				}
				if (view instanceof EditText) {

					if (((EditText) view).getTag().equals("热源泵厂家")) {
						mRYPumpEntity.setManufactorRY(((EditText) view)
								.getText().toString());

					} else if (((EditText) view).getTag().equals("热源泵型号")) {
						mRYPumpEntity.setModelRY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热源泵流量")) {
						mRYPumpEntity.setFlowRY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热源泵扬程")) {
						mRYPumpEntity.setLiftRY(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("热源泵用")) {
						mRYPumpEntity.setQuantityRY(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得主用");
					} else if (((EditText) view).getTag().equals("热源泵备")) {
						mRYPumpEntity.setDeviceRY(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得备用");

					}
				}
			}
			listRY.add(mRYPumpEntity);
		}
		return listRY;

	}

	/**
	 * 递归遍历所有动态添加的组件,获取用户输入的热源泵数据
	 * 
	 * @param viewGroup
	 *            LinearLayout
	 */

	public ArrayList<LQTPumpEntity> traversalViewForLQT(ViewGroup viewGroup) {

		int count = viewGroup.getChildCount();
		LQTPumpEntity mLQTPumpEntity = null;
		for (int i = 0; i < count; i++) {
			mLQTPumpEntity = new LQTPumpEntity();
			View view = viewGroup.getChildAt(i);
			if (view instanceof ViewGroup) {
				traversalViewForLQT((ViewGroup) view);
			} else {
				if (view instanceof TextView) {
					if (((TextView) view).getText().toString().equals("冷却塔")) {
						mLQTPumpEntity.setPumpLQT(((TextView) view).getText()
								.toString());
					}
				}
				if (view instanceof EditText) {

					if (((EditText) view).getTag().equals("冷却塔厂家")) {
						mLQTPumpEntity.setManufactorLQT(((EditText) view)
								.getText().toString());

					} else if (((EditText) view).getTag().equals("冷却塔型号")) {
						mLQTPumpEntity.setModelLQT(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("冷却塔流量")) {
						mLQTPumpEntity.setFlowLQT(((EditText) view).getText()
								.toString());

					} else if (((EditText) view).getTag().equals("冷却塔能力")) {
						mLQTPumpEntity.setAbilityLQT(((EditText) view)
								.getText().toString());

					} else if (((EditText) view).getTag().equals("冷却塔数量")) {
						mLQTPumpEntity.setAmountLQT(((EditText) view).getText()
								.toString());
						// Log.i("DATA", "获得主用");
					}
				}
			}
			listLQT.add(mLQTPumpEntity);
		}
		return listLQT;

	}

	/**
	 * 将热回收泵实体数据添加到大机组实体
	 * 
	 * @param viewGroup
	 */
	public void getDataForLQTPump(ViewGroup viewGroup) {

		ArrayList<LQTPumpEntity> dataForLQTPumpList = new ArrayList<LQTPumpEntity>();
		dataForLQTPumpList = traversalViewForLQT(viewGroup);

		int index = 0;
		if (sub_LQTPumpNum != 0) {
			for (int j = 0; j < sub_LQTPumpNum; j++) {
				if (j == 0) {
					for (int i = 0; i < dataForLQTPumpList.size(); i++) {
						if (dataForLQTPumpList.get(i).getPumpLQT() != "") {
							dataForBigUnit.setPumpLQT1("冷却塔1");

						}
						if (dataForLQTPumpList.get(i).getManufactorLQT() != "") {
							dataForBigUnit.setManufactorLQT1(dataForLQTPumpList
									.get(i).getManufactorLQT());

						}
						if (dataForLQTPumpList.get(i).getModelLQT() != "") {
							dataForBigUnit.setModelLQT1(dataForLQTPumpList.get(
									i).getModelLQT());

						}

						if (dataForLQTPumpList.get(i).getFlowLQT() != "") {
							dataForBigUnit.setFlowLQT1(dataForLQTPumpList
									.get(i).getFlowLQT());

						}

						if (dataForLQTPumpList.get(i).getAbilityLQT() != "") {
							dataForBigUnit.setAbilityLQT1(dataForLQTPumpList
									.get(i).getAbilityLQT());

						}
						if (dataForLQTPumpList.get(i).getAmountLQT() != "") {
							dataForBigUnit.setAmountLQT1(dataForLQTPumpList
									.get(i).getAmountLQT());

							index = i;
							break;
						}

					}

				}
				if (j == 1) {
					for (int i = (index + 1); i < dataForLQTPumpList.size(); i++) {
						if (dataForLQTPumpList.get(i).getPumpLQT() != "") {
							dataForBigUnit.setPumpLQT2("冷却塔2");

						}
						if (dataForLQTPumpList.get(i).getManufactorLQT() != "") {
							dataForBigUnit.setManufactorLQT2(dataForLQTPumpList
									.get(i).getManufactorLQT());

						}
						if (dataForLQTPumpList.get(i).getModelLQT() != "") {
							dataForBigUnit.setModelLQT2(dataForLQTPumpList.get(
									i).getModelLQT());

						}

						if (dataForLQTPumpList.get(i).getFlowLQT() != "") {
							dataForBigUnit.setFlowLQT2(dataForLQTPumpList
									.get(i).getFlowLQT());

						}

						if (dataForLQTPumpList.get(i).getAbilityLQT() != "") {
							dataForBigUnit.setAbilityLQT2(dataForLQTPumpList
									.get(i).getAbilityLQT());

						}
						if (dataForLQTPumpList.get(i).getAmountLQT() != "") {
							dataForBigUnit.setAmountLQT2(dataForLQTPumpList
									.get(i).getAmountLQT());

						}

					}
				}
			}

		}

	}

	/**
	 * 将热源泵实体数据添加到大机组实体
	 * 
	 * @param viewGroup
	 */
	public void getDataForRYPump(ViewGroup viewGroup) {
		// Log.i("DAtA", "getDataForSYPump");
		ArrayList<RYPumpEntity> dataForRYPumpList = new ArrayList<RYPumpEntity>();
		dataForRYPumpList = traversalViewForRY(viewGroup);

		int index = 0;
		if (sub_RYPumpNum != 0) {
			for (int j = 0; j < sub_RYPumpNum; j++) {
				if (j == 0) {
					for (int i = 0; i < dataForRYPumpList.size(); i++) {
						if (dataForRYPumpList.get(i).getPumpRY() != "") {
							dataForBigUnit.setPumpRY1("热源泵1");

						}
						if (dataForRYPumpList.get(i).getManufactorRY() != "") {
							dataForBigUnit.setManufactorRY1(dataForRYPumpList
									.get(i).getManufactorRY());

						}
						if (dataForRYPumpList.get(i).getModelRY() != "") {
							dataForBigUnit.setModelRY1(dataForRYPumpList.get(i)
									.getModelRY());

						}

						if (dataForRYPumpList.get(i).getFlowRY() != "") {
							dataForBigUnit.setFlowRY1(dataForRYPumpList.get(i)
									.getFlowRY());

						}
						if (dataForRYPumpList.get(i).getLiftRY() != "") {
							dataForBigUnit.setLiftRY1(dataForRYPumpList.get(i)
									.getLiftRY());

						}
						if (dataForRYPumpList.get(i).getQuantityRY() != "") {
							dataForBigUnit.setQuantityRY1(dataForRYPumpList
									.get(i).getQuantityRY());

						}
						if (dataForRYPumpList.get(i).getDeviceRY() != "") {
							dataForBigUnit.setDeviceRY1(dataForRYPumpList
									.get(i).getDeviceRY());

							index = i;
							break;
						}

					}

				}
				if (j == 1) {
					for (int i = (index + 1); i < dataForRYPumpList.size(); i++) {
						if (dataForRYPumpList.get(i).getPumpRY() != "") {
							dataForBigUnit.setPumpRY2("热源泵2");

						}
						if (dataForRYPumpList.get(i).getManufactorRY() != "") {
							dataForBigUnit.setManufactorRY2(dataForRYPumpList
									.get(i).getManufactorRY());

						}
						if (dataForRYPumpList.get(i).getModelRY() != "") {
							dataForBigUnit.setModelRY2(dataForRYPumpList.get(i)
									.getModelRY());

						}

						if (dataForRYPumpList.get(i).getFlowRY() != "") {
							dataForBigUnit.setFlowRY2(dataForRYPumpList.get(i)
									.getFlowRY());

						}
						if (dataForRYPumpList.get(i).getLiftRY() != "") {
							dataForBigUnit.setLiftRY2(dataForRYPumpList.get(i)
									.getLiftRY());

						}
						if (dataForRYPumpList.get(i).getQuantityRY() != "") {
							dataForBigUnit.setQuantityRY2(dataForRYPumpList
									.get(i).getQuantityRY());

						}
						if (dataForRYPumpList.get(i).getDeviceRY() != "") {
							dataForBigUnit.setDeviceRY2(dataForRYPumpList
									.get(i).getDeviceRY());

							index = i;
							break;
						}

					}
				}
				if (j == 2) {
					for (int i = (index + 1); i < dataForRYPumpList.size(); i++) {
						if (dataForRYPumpList.get(i).getPumpRY() != "") {
							dataForBigUnit.setPumpRY3("热源泵3");

						}
						if (dataForRYPumpList.get(i).getManufactorRY() != "") {
							dataForBigUnit.setManufactorRY3(dataForRYPumpList
									.get(i).getManufactorRY());

						}
						if (dataForRYPumpList.get(i).getModelRY() != "") {
							dataForBigUnit.setModelRY3(dataForRYPumpList.get(i)
									.getModelRY());

						}

						if (dataForRYPumpList.get(i).getFlowRY() != "") {
							dataForBigUnit.setFlowRY3(dataForRYPumpList.get(i)
									.getFlowRY());

						}
						if (dataForRYPumpList.get(i).getLiftRY() != "") {
							dataForBigUnit.setLiftRY3(dataForRYPumpList.get(i)
									.getLiftRY());

						}
						if (dataForRYPumpList.get(i).getQuantityRY() != "") {
							dataForBigUnit.setQuantityRY3(dataForRYPumpList
									.get(i).getQuantityRY());

						}
						if (dataForRYPumpList.get(i).getDeviceRY() != "") {
							dataForBigUnit.setDeviceRY3(dataForRYPumpList
									.get(i).getDeviceRY());

						}

					}
				}
			}

		}

	}

	/**
	 * 将使用泵实体数据添加到大机组实体
	 * 
	 * @param viewGroup
	 */
	public void getDataForSYPump(ViewGroup viewGroup) {
		// Log.i("DAtA", "getDataForSYPump");
		ArrayList<SYPumpEntity> dataForSYPumpList = new ArrayList<SYPumpEntity>();
		dataForSYPumpList = traversalViewForSY(viewGroup);

		int index = 0;
		if (sub_SYPumpNum != 0) {
			for (int j = 0; j < sub_SYPumpNum; j++) {
				if (j == 0) {
					for (int i = 0; i < dataForSYPumpList.size(); i++) {
						if (dataForSYPumpList.get(i).getPumpSY() != "") {
							dataForBigUnit.setPumpSY1("使用泵1");

						}
						if (dataForSYPumpList.get(i).getManufactorSY() != "") {
							dataForBigUnit.setManufactorSY1(dataForSYPumpList
									.get(i).getManufactorSY());

						}
						if (dataForSYPumpList.get(i).getModelSY() != "") {
							dataForBigUnit.setModelSY1(dataForSYPumpList.get(i)
									.getModelSY());

						}

						if (dataForSYPumpList.get(i).getFlowSY() != "") {
							dataForBigUnit.setFlowSY1(dataForSYPumpList.get(i)
									.getFlowSY());

						}
						if (dataForSYPumpList.get(i).getLiftSY() != "") {
							dataForBigUnit.setLiftSY1(dataForSYPumpList.get(i)
									.getLiftSY());

						}
						if (dataForSYPumpList.get(i).getQuantitySY() != "") {
							dataForBigUnit.setQuantitySY1(dataForSYPumpList
									.get(i).getQuantitySY());

						}
						if (dataForSYPumpList.get(i).getDeviceSY() != "") {
							dataForBigUnit.setDeviceSY1(dataForSYPumpList
									.get(i).getDeviceSY());

							index = i;
							break;
						}

					}

				}
				if (j == 1) {
					for (int i = (index + 1); i < dataForSYPumpList.size(); i++) {
						if (dataForSYPumpList.get(i).getPumpSY() != "") {
							dataForBigUnit.setPumpSY2("使用泵2");

						}
						if (dataForSYPumpList.get(i).getManufactorSY() != "") {
							dataForBigUnit.setManufactorSY2(dataForSYPumpList
									.get(i).getManufactorSY());

						}
						if (dataForSYPumpList.get(i).getModelSY() != "") {
							dataForBigUnit.setModelSY2(dataForSYPumpList.get(i)
									.getModelSY());

						}

						if (dataForSYPumpList.get(i).getFlowSY() != "") {
							dataForBigUnit.setFlowSY2(dataForSYPumpList.get(i)
									.getFlowSY());

						}
						if (dataForSYPumpList.get(i).getLiftSY() != "") {
							dataForBigUnit.setLiftSY2(dataForSYPumpList.get(i)
									.getLiftSY());

						}
						if (dataForSYPumpList.get(i).getQuantitySY() != "") {
							dataForBigUnit.setQuantitySY2(dataForSYPumpList
									.get(i).getQuantitySY());

						}
						if (dataForSYPumpList.get(i).getDeviceSY() != "") {
							dataForBigUnit.setDeviceSY2(dataForSYPumpList
									.get(i).getDeviceSY());

							index = i;
							break;
						}

					}
				}
				if (j == 2) {
					for (int i = (index + 1); i < dataForSYPumpList.size(); i++) {
						if (dataForSYPumpList.get(i).getPumpSY() != "") {
							dataForBigUnit.setPumpSY3("使用泵3");

						}
						if (dataForSYPumpList.get(i).getManufactorSY() != "") {
							dataForBigUnit.setManufactorSY3(dataForSYPumpList
									.get(i).getManufactorSY());

						}
						if (dataForSYPumpList.get(i).getModelSY() != "") {
							dataForBigUnit.setModelSY3(dataForSYPumpList.get(i)
									.getModelSY());

						}

						if (dataForSYPumpList.get(i).getFlowSY() != "") {
							dataForBigUnit.setFlowSY3(dataForSYPumpList.get(i)
									.getFlowSY());

						}
						if (dataForSYPumpList.get(i).getLiftSY() != "") {
							dataForBigUnit.setLiftSY3(dataForSYPumpList.get(i)
									.getLiftSY());

						}
						if (dataForSYPumpList.get(i).getQuantitySY() != "") {
							dataForBigUnit.setQuantitySY3(dataForSYPumpList
									.get(i).getQuantitySY());

						}
						if (dataForSYPumpList.get(i).getDeviceSY() != "") {
							dataForBigUnit.setDeviceSY3(dataForSYPumpList
									.get(i).getDeviceSY());

						}

					}
				}
			}

		}

	}

	/**
	 * 将热回收泵实体数据添加到大机组实体
	 * 
	 * @param viewGroup
	 */
	public void getDataForRHSPump(ViewGroup viewGroup) {
		// Log.i("DAtA", "getDataForRHSPump");
		ArrayList<RHSPumpEntity> dataForRHSPumpList = new ArrayList<RHSPumpEntity>();
		dataForRHSPumpList = traversalViewForRHS(viewGroup);

		int index = 0;
		if (sub_RHSPumpNum != 0) {
			for (int j = 0; j < sub_RHSPumpNum; j++) {
				if (j == 0) {
					for (int i = 0; i < dataForRHSPumpList.size(); i++) {
						if (dataForRHSPumpList.get(i).getPumpRHS() != "") {
							dataForBigUnit.setPumpRHS1("热回收泵1");

						}
						if (dataForRHSPumpList.get(i).getManufactorRHS() != "") {
							dataForBigUnit.setManufactorRHS1(dataForRHSPumpList
									.get(i).getManufactorRHS());

						}
						if (dataForRHSPumpList.get(i).getModelRHS() != "") {
							dataForBigUnit.setModelRHS1(dataForRHSPumpList.get(
									i).getModelRHS());

						}

						if (dataForRHSPumpList.get(i).getFlowRHS() != "") {
							dataForBigUnit.setFlowRHS1(dataForRHSPumpList
									.get(i).getFlowRHS());

						}
						if (dataForRHSPumpList.get(i).getLiftRHS() != "") {
							dataForBigUnit.setLiftRHS1(dataForRHSPumpList
									.get(i).getLiftRHS());

						}
						if (dataForRHSPumpList.get(i).getQuantityRHS() != "") {
							dataForBigUnit.setQuantityRHS1(dataForRHSPumpList
									.get(i).getQuantityRHS());

						}
						if (dataForRHSPumpList.get(i).getDeviceRHS() != "") {
							dataForBigUnit.setDeviceRHS1(dataForRHSPumpList
									.get(i).getDeviceRHS());

							index = i;
							break;
						}

					}

				}
				if (j == 1) {
					for (int i = (index + 1); i < dataForRHSPumpList.size(); i++) {
						if (dataForRHSPumpList.get(i).getPumpRHS() != "") {
							dataForBigUnit.setPumpRHS2("热回收泵2");

						}
						if (dataForRHSPumpList.get(i).getManufactorRHS() != "") {
							dataForBigUnit.setManufactorRHS2(dataForRHSPumpList
									.get(i).getManufactorRHS());

						}
						if (dataForRHSPumpList.get(i).getModelRHS() != "") {
							dataForBigUnit.setModelRHS2(dataForRHSPumpList.get(
									i).getModelRHS());

						}

						if (dataForRHSPumpList.get(i).getFlowRHS() != "") {
							dataForBigUnit.setFlowRHS2(dataForRHSPumpList
									.get(i).getFlowRHS());

						}
						if (dataForRHSPumpList.get(i).getLiftRHS() != "") {
							dataForBigUnit.setLiftRHS2(dataForRHSPumpList
									.get(i).getLiftRHS());

						}
						if (dataForRHSPumpList.get(i).getQuantityRHS() != "") {
							dataForBigUnit.setQuantityRHS2(dataForRHSPumpList
									.get(i).getQuantityRHS());

						}
						if (dataForRHSPumpList.get(i).getDeviceRHS() != "") {
							dataForBigUnit.setDeviceRHS2(dataForRHSPumpList
									.get(i).getDeviceRHS());

						}

					}
				}
			}

		}

	}

	/**
	 * 获取当前日期作为身份码
	 * 
	 * @return
	 */
	public String getNowDateAsIdentityCode() {

		final MachineCodeUtil codeUtil = new MachineCodeUtil(activity);
		String time = String.valueOf(System.currentTimeMillis());
		String a = time.substring(time.length() - 4, time.length());
		String imeiCode = codeUtil.getIMEICode();
		final String identityCode = imeiCode.substring(imeiCode.length() - 4,
				imeiCode.length()) + a;
		return identityCode;

	}

	
}
